package com.ilink.groundservice.mapper.dataset;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ilink.groundservice.entity.PO.dataset.DatasetTags;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <h3>iLink-java-backend-zhangbo2</h3>
 *
 * @Description <p>与数据库表【dataset_tags】的交互</p>
 * @Author ZhangBo
 * @Date 2024-09-15 21:11
 **/
@Mapper
public interface DatasetTagsMapper extends BaseMapper<DatasetTags> {
    @Select("SELECT tag FROM dataset_tags " +
        "WHERE tag IS NOT NULL AND tag <> '' " +
        "GROUP BY tag " +
        "ORDER BY COUNT(*) DESC " +
        "LIMIT #{num}")
    List<String> selectCommonTags(int num);

    @Select("SELECT COUNT(DISTINCT tag) FROM dataset_tags")
    long selectTagsCount();
}
